import {
    List
} from 'vant';
import {
    getCommentList
} from '@/api/api.js';

export default {
    components: {
        [List.name]: List
    },
    data() {
        return {
            commentList: [],
            skip: 0,
            limit: 10,
            commentLoading: false,
            commentFinished: false,
            comment_count: [] //评论数量
        }
    },



    methods: {
        getCommentList() {
            let {
                uid,
                article_id,
                skip,
                limit
            } = this
            getCommentList({
                user_id: uid,
                article_id,
                skip,
                limit
            }).then(res => {
                console.log(res);
                if (res.code == 0) {

                    this.commentList.push(...res.data)

                    let len = this.commentList.length;
                    if (len >= res.count) {
                        this.commentFinished = true
                    } else {
                        this.commentLoading = false
                        this.skip = len
                    }
                    this.comment_count = res.count
                } else {
                    this.$toast(res.msg)
                }
            })
        }
    },
}